﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using Utilities.QuickSql;

namespace showcolat
{
    public partial class FormConnexion : Form
    {
        //private FormAccueil accueil;
        public FormConnexion()
        {
            InitializeComponent();
        }

        public FormConnexion(FormAccueil accueil)
        {
            InitializeComponent();
            FormAccueil F_accueil = accueil;
            
            //accueil.Show();
            
        }

        private void Bconnexion_Click(object sender, EventArgs e)
        {
            DBconnect db = new DBconnect();
            FormAccueil l = new FormAccueil();
            List<user> list_user = db.Conn_user(Tbox_user.Text.ToString(), Tbox_mdp.Text.ToString());
            foreach (user d in list_user)
            {

                if (d.CPseudo_user == Tbox_user.Text.ToString() && d.mdp_user == Tbox_mdp.Text.ToString())
                {

                    
                    this.Close();
                    FormAccueil accueil = new FormAccueil(d.CId_user);
                    accueil.ShowDialog();
                    
                }
                else
                    MessageBox.Show("Identifiant ou mot de passe incorrect");
            }            
        }
    }
}
